package com.shop.advertisement.controller;

import com.shop.advertisement.service.SearchSlideAdService;
import com.shop.pojo.LdbzSearchSlideAd;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/search/slide/ad/")
public class SearchSlideAdController {
    private static final Logger logger = LoggerFactory.getLogger(SearchSlideAdController.class);
    @Autowired
    private SearchSlideAdService searchSlideAdService;

    @RequestMapping(value = "/getSearchSlideAdPage", method = RequestMethod.GET)
    public List<LdbzSearchSlideAd> getSearchSlideAdPage(@RequestParam("entity") LdbzSearchSlideAd entity, @RequestParam("start") int start, @RequestParam("limit") int limit) {
        return searchSlideAdService.getSearchSlideAdPage(entity, start, limit);
    }

    @RequestMapping(value = "/countByEntity", method = RequestMethod.GET)
    public long countByEntity(@RequestParam("entity") LdbzSearchSlideAd entity) {
        return searchSlideAdService.countByEntity(entity);
    }

    @RequestMapping(value = "/selectByKey/{id}", method = RequestMethod.GET)
    public LdbzSearchSlideAd selectByKey(@RequestParam("id") Long id) {
        return searchSlideAdService.selectByKey(id);
    }

    @RequestMapping(value = "/deleteByKey/{id}", method = RequestMethod.GET)
    public int deleteByKey(@RequestParam("id") Long id) {
        return searchSlideAdService.deleteByKey(id);
    }

    @RequestMapping(value = "/deleteByKeys{ids}", method = RequestMethod.GET)
    public int deleteByKeys(@RequestParam("ids") List<Long> ids) {
        return searchSlideAdService.deleteByKeys(ids);
    }

    @RequestMapping(value = "/insertByEntity", method = RequestMethod.GET)
    public int insertByEntity(@RequestParam("entity") LdbzSearchSlideAd entity) {
        return searchSlideAdService.insertByEntity(entity);
    }

    @RequestMapping(value = "/search/slide/ad/update", method = RequestMethod.GET)
    int updateByKey(@RequestParam("entity") LdbzSearchSlideAd entity) {
        return searchSlideAdService.updateByKey(entity);
    }

    @RequestMapping(value = "/getSearchSlideAdByRedis")
    public List<LdbzSearchSlideAd> getSearchSlideAdByRedis() {
        return searchSlideAdService.getSearchSlideAdByRedis();
    }
}
